home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_03
/
1003070a
< prev
next >
Wrap
Text File
|
1992-01-11
|
264b
|
25 lines
Listing 3
//
// gcd.cpp
//
#include <stdlib.h>
#include "mylib.h"
long gcd(long x, long y)
{
ldiv_t r;
x = labs(x);
if ((y = labs(y)) == 0)
return x;
do
{
r = ldiv(x, y);
x = y;
}
while ((y = r.rem) != 0);
return x;
}